(ns ura.MenuSide
  (:require
   [reagent.core :as r]
   [reagent.dom :as rd]
   [reitit.frontend :as rf]
   [reitit.frontend.easy :as rfe]

   [ura.common :as uc :refer [log spy]]
   [ura.style :refer [attr]]

   [re-com.core :as rc]
   ))


(attr "side-bar-item"
      :font-size=20px
      :pl=30px
      :pt=8px
      :pb=8px
      )
(attr "side-bar-item:hover"
      :bgc=blue-900
      :cursor=pointer
      )

(attr "side-bar-item-active"
      :color=black
      :bgc=#09396D
      )

(def menulist [
               {:label "账号管理" :name :user :icon :.mdi-account-multiple}
               {:label "组织管理" :name :org  :icon :.mdi-sitemap}
               {:label "角色管理" :name :role :icon :.mdi-account-box}
               {:label "权限管理" :name :auth :icon :.mdi-lock-check-outline}
               {:label "日志管理" :name :log  :icon :.mdi-script-text-outline}
               ])

(defn side-menu [match]
  (let [router match
        menu (:name (:data match))
        ]
    [:div.side-bar (attr :w=100%)
     (into [:div ]
           (map (fn [m]
                  [:div (attr
                         (when (= (name (:name m)) menu) :.side-bar-item-active)
                         :.side-bar-item
                         {:on-click (fn []
                                      (log "in menu: "  menu (name (:name m)))
                                      (rfe/push-state (:name m))
                                      )}
                         )
                   [:span (attr :color=white)
                    [:i (attr :.mdi :mr=10px :w=22 (:icon m))]
                    (:label m)
                    ]
                   ]
                  )
                menulist)
           )
     ]
    )
  )

